<template>
	<view>
		<view class="login">
			<view class="ava">
				<view class="ava-img">
					<image src="../../static/icons/leju-logo.png" mode=""></image>
				</view>
			</view>

		</view>
		<view class="ipts">
			<view class="ipts-t">
				<input type="text" value="" placeholder="手机号" v-model="phone" />
			</view>
			<view class="ipts-b">
				<input type="password" value="" placeholder="登录密码"  v-model="password"/>
			</view>
			<view class="ipts-b">
				<input type="text" value="" placeholder="用户名"  v-model="username"/>
			</view>
			<view class="ipts-b">
				<input type="text" value="" placeholder="昵称"  v-model="nickname"/>
			</view>
			<view class="ipts-b">
				<input type="text" value="" placeholder="验证码"  v-model="yz"/>
			</view>
		</view>
		<view class="login-btn">
			<button type="default" @tap="registerNum">注册</button>
		</view>
		<view class="footer">
			<!-- <view class="footer-l">
				找回密码
			</view>
			<view class="line">
				
			</view>
			<view class="footer-r" @tap="registerNum">
				注册账号
			</view> -->
			<view class="round" @tap="agree">
				<view class="dot" v-if="flag">
					
				</view>
			</view>
			<view class="xieyi">
				同意 《协议》
			</view>
		</view>
	</view>
</template>

<script>
	import{login,register} from "../../utils/login/index.js"
	export default {
		data() {
			return {
				username:'',
				password:"",
				nickname:"",
				phone:"",
				flag:false,
				yz:'123'
			}
		},
		methods: {
			agree(){
				this.flag=!this.flag
			},
		registerNum(){
			if(!this.flag){
				uni.showToast({
					title:"请先同意此协议",
					icon:"none"
				})
			}else{
				register({
					// birthday:"1998-10-24",
					  city: "鹤壁",
					  // createTime: "2020-12-27",
					  email: "3136958283@qq.com",
					  growth: 0,
					  historyIntegration: 0,
					  icon: "string",
					  id: "",
					  integration: 0,
					  isDisabled: 0,
					  memberLevelId: "",
					  // modifyTime: "2020-12-27T06:56:57.419Z",
					  nickname: this.nickname,
					  password: this.password,
					  personalizedSignature: "",
					  phone: this.phone,
					  realname: "123",
					  sex: 0,
					  sourceType: 0,
					  status: 0,
					  username: this.username,
					  // wxOpenId: "wx81fb1736b9510344"
					
				}).then(res=>{
					console.log(res)
					if(res.success==true){
						uni.showToast({
							title:"注册成功,1秒钟之后自动跳转",
							icon: 'none',
							duration:1000
						})
						 setTimeout(()=>{
						      uni.navigateTo({
						      	 url: '/pages/login/login',
						      })
						    },1000)
					}else{
						uni.showToast({
							title:"用户名/手机号已经被注册",
							icon:"none"
						})
					}
					
					
				})
			}
			
		}
		}
	}
</script>

<style scoped lang="scss">
	.login {
		width: 90%;
		margin: 0 auto;
		display: flex;
		justify-content: center;
		align-items: center;
		.ava {
			width: 160rpx;
			height: 160rpx;
			box-shadow: 0rpx 0rpx 60rpx 0px rgba(0, 0, 0, .1);
			border-radius: 50%;
			background-color: #000;
			margin-top: 128rpx;
			margin-bottom: 72rpx;
			margin-left: auto;
			margin-right: auto;
			.ava-img {
				width: 160rpx;
				height: 160rpx;
				border-radius: 50%;
				overflow: hidden;
				image {
					width: 100%;
					height: 100%;
				}
			}
		}

	}

	.ipts {
		width: 90%;
		margin: 0 auto;

		.ipts-t,
		.ipts-b {
			height: 100rpx;
			border: none;
			border-radius: 40rpx;
			box-shadow: 0 0 60rpx 0 rgba(43, 86, 112, .1);
			margin-top: 30rpx;

			input {
				position: relative;
				display: block;
				height: 100%;
				background: none;
				color: inherit;
				opacity: 1;
				font: inherit;
				line-height: inherit;
				letter-spacing: inherit;
				text-align: inherit;
				text-indent: inherit;
				text-transform: inherit;
				text-shadow: inherit;
				width: 80%;
				margin: 0 auto;
			}
		}
	}

	.login-btn {
		width: 90%;
		margin: 0 auto;
		margin-top: 50rpx;

		button {
			width: 100%;
		
			background: rgb(53, 78, 68);
			color: rgb(255, 255, 255);
			border-radius: 50rpx;
		}
	}

	.footer {
		width: 90%;
		margin: 0 auto;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		margin-top: 40rpx;
		color: rgba(0, 0, 0, .7);
		text-align: center;
		height: 40rpx;
		line-height: 40rpx;
		.round{
			width: 24rpx;
			height: 24rpx;
			border-radius: 50%;
			border: 1px solid #333333;
			display: flex;
			justify-content: center;
			align-items: center;
		}
		.dot{
			
			width: 10rpx;
			height: 10rpx;
			border-radius: 50%;
			background-color: #333333;
			
		}
		.xieyi{
			margin-left: 30rpx;
			font-size: 20rpx;
		}
	}
</style>
